<?php
header("Content-type:text/html; charset=utf-8");
require_once ('include/conn.php');
require_once ('system.class.php');
function article($args, $content, &$smarty){
	$article_id=$args['article_id'];
	$channel_id=$args['channel_id'];
	
	/*用于判断是否转向404页面*/
	$arr['error_page']='false';
	$arr['error_page_url']=CIE."/404.php";
	/*获取文章所在栏目信息*/
		$article_channel_information=getArticleChannelInformation($channel_id);
		if($article_channel_information!=""){
		$arr['channel_name']=$article_channel_information['channel_name'];
		$arr['url']=CIE."/channel.php?channel_id=$channel_id";
		}
		else{
		$arr['error_page']='true';
			$smarty->assign("article",$arr);
	        return $content;	
		}
		
	/*获取文章信息*/
	$sql_get_article_information="select article_title,article_publish_time,article_from,article_click,article_content 
	from article_normal where article_status=1 and article_id=$article_id;";
	$result_get_article_information=mysql_query($sql_get_article_information);
	$num_article_information=mysql_num_rows($result_get_article_information);
	if($num_article_information>0){
		while($row_get_article_information=mysql_fetch_row($result_get_article_information)){
			$arr['id']=$article_id;
			$arr['title']=$row_get_article_information[0];
			$arr['publish_time']=date('Y-m-d H:i:s',$row_get_article_information[1]);
			$arr['from']=$row_get_article_information[2];
			$arr['content']=base64_decode($row_get_article_information[4]);
			$arr['click']=$row_get_article_information[3];
		}
	}
	if($num_article_information==0){
	$arr['error_page']='true';
	}
	$smarty->assign("article",$arr);
	return $content;
}
function getArticleChannelInformation($channel_id){
	$sql_get_article_channel_information="select channel_name,channel_visit_path,is_bottom from channel where channel_id=$channel_id";
	$result_get_article_channel_information=mysql_query($sql_get_article_channel_information) or die(mysql_error());
	$num=mysql_num_rows($result_get_article_channel_information);
	if($num!=0){
	$row_get_article_channel_information=mysql_fetch_row($result_get_article_channel_information);
	return array("channel_name"=>$row_get_article_channel_information[0],"channel_visit_path"=>$row_get_article_channel_information[1],"is_bottom"=>$row_get_article_channel_information[2]);
}else{
    return "";
}
}
function getArticleTitleInfo($article_id){
	$sql_get_article_title_info="select article_title from article_normal where article_id=$article_id";
	$result_get_article_title_info=mysql_query($sql_get_article_title_info);
	$num=mysql_num_rows($result_get_article_title_info);
	if($num==0){
		return "";
	}
	$row_get_article_title_info=mysql_fetch_row($result_get_article_title_info);
	return $row_get_article_title_info[0];
}